layui.use(['form', 'table', 'laydate'], function () {
    var form = layui.form,
        layer = layui.layer,
        table = layui.table,
        $ = layui.$,
        laydate = layui.laydate;

    $(function(){
        // 评论插件：绑定表情
        $('.face-icon').SinaEmotion($('.text'));
    });

    /**
     * 初始化表单，要加上，不然刷新部分组件可能会不加载
     */
    form.render();

    // 当前弹出层，防止ID被覆盖
    var parentIndex = layer.index;

    //监听提交
    form.on('submit(saveBtn)', function (data) {
        layer.msg("发布中...", {icon:6});
        var url = "/blogSpace/sendLoveList";
        $.post(url, data.field, function(res){
            if(res.state == "200"){
                layer.msg(res.message, {icon:6});
                //刷新
                setTimeout(function(){
                    location.reload();
                }, 2000);
            }else{
                layer.msg(res.message, {icon:2});
            }
        }, 'json');

        // 关闭弹出层
        layer.close(parentIndex);

        return false;
    });


    $("#closeBtn").on("click", function(){
        // 关闭弹出层
        layer.close(parentIndex);
    });

});